package practice.w903;

import java.util.Random;
import java.util.Scanner;

public class GuessingDemo {
    public static void main(String[] args) {
        Random rand = new Random();
        int answer = rand.nextInt(100);
        System.out.println(answer);
        Scanner sc = new Scanner(System.in);
        while (true) {//自造死循环
            System.out.println("猜吧");
            int guess = sc.nextInt();
            if (guess > answer) System.out.println("猜大了");
            else if (guess < answer) System.out.println("猜小了");
            else {
                System.out.println("猜对了");
                break;//跳出循环
            }
        }
    }
}
